package com.seth.myapplication;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.seth.myapplication.bean.Rewords;
import com.seth.myapplication.helper.SetStatusTabHeight;
import com.seth.myapplication.surface.AcceptTask;

/**
 * Created by Seth on 2017/10/23.
 */

public class AcceptActivity extends FragmentActivity {
    private static final String EXTRA_TASK_POSITION = "00000000";
    public static final String EXTRA_FLAG = "flag";
    private Rewords reword;
    private FragmentManager fm;
    private int flag = 0;

    private LinearLayout topStatus;

    public static Intent newIntent(Context context, Rewords rewords, int i) {
        Rewords r = rewords;
        Intent intent = new Intent(context,AcceptActivity.class);
        intent.putExtra(EXTRA_TASK_POSITION, r);
        intent.putExtra(EXTRA_FLAG,i);

        return intent;


    }

    public static Intent newIntent(Context context, Rewords rewords) {
        Rewords r = rewords;
        Intent intent = new Intent(context,AcceptActivity.class);
        intent.putExtra(EXTRA_TASK_POSITION, r);

        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        setContentView(R.layout.activity_accept);

        Intent i = getIntent();
        reword = (Rewords) i.getSerializableExtra(EXTRA_TASK_POSITION);
        flag = i.getIntExtra(EXTRA_FLAG,0);

        initView();
        initEvent();
    }

    private void initEvent() {
        new SetStatusTabHeight(topStatus,this).setRelativeLayout();

        Fragment fragment = new AcceptTask();

        Bundle bundle = new Bundle();
        bundle.putSerializable(EXTRA_TASK_POSITION,reword);
        bundle.putInt(EXTRA_FLAG,flag);
        fragment.setArguments(bundle);


        fm = getSupportFragmentManager();
       // fragment = fm.findFragmentById(R.id.accept_content);
        fm.beginTransaction().add(R.id.accept_content, fragment).commit();
    }
    private void initView() {
        topStatus = (LinearLayout) findViewById(R.id.accept_top_sts);
    }



}
